package com.haq.housesystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.haq.housesystem.bean.Houses;
import com.haq.housesystem.bean.HousesType;
import com.haq.housesystem.dao.HousesTypeDao;
import com.haq.housesystem.service.HousesTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class HousesTypeServiceImpl implements HousesTypeService {
    @Autowired
    HousesTypeDao housesTypeDao;
    @Override
    public void insert(HousesType housesType) {
        housesTypeDao.insert(housesType);
    }

    @Override
    public void update(HousesType housesType) {
        housesTypeDao.update(housesType);
    }

    @Override
    public void delete(int typeId) {
        housesTypeDao.delete(typeId);
    }

    @Override
    public void deleteByIds(int[] typeIds) {
        housesTypeDao.deleteByIds(typeIds);
    }

    @Override
    public List<HousesType> selectAll() {
        List<HousesType> list=housesTypeDao.selectAll();
        return list;
    }

    @Override
    public HousesType selectById(int typeId) {

       HousesType housesType=housesTypeDao.selectById(typeId);
       return housesType;
    }

    @Override
    public List<HousesType> selectByName(String typeName) {

        List<HousesType>  list=housesTypeDao.selectByName(typeName);
        return list;

    }

    @Override
    public int getNumer() {
        return 0;
    }

    @Override
    public PageInfo<HousesType> selectAllByPageInfo(int curPage, int size) {
        PageHelper.startPage(curPage, size);
        List<HousesType> list = housesTypeDao.selectAll();
        PageInfo<HousesType> pageInfo=new PageInfo<HousesType>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<HousesType> selectByNameByPageInfo(int curPage, int size, String typeName) {
        PageHelper.startPage(curPage, size);
        List<HousesType> list = housesTypeDao.selectByName(typeName);
        PageInfo<HousesType> pageInfo=new PageInfo<HousesType>(list);
        return pageInfo;
    }
}
